from agent import agent
from packetholder import packetholder

class sink(agent):
  holder = None

  def __init__(self):
    super(sink, self).__init__()

    self.holder = packetholder()
    self.holder.max_flits = 100

  def accept(self, src_node, inc_pkt, max_trans_f, route_hint=None):
    return self.holder.accept(inc_pkt, max_trans_f)

  def process(self):
    remove_list = []
  
    for pkt in self.holder.contents:
      if (pkt.valid()):
        print "Sink Consuming Packet"
        remove_list.append(pkt)

    for victim in remove_list:
      self.holder.contents.remove(victim)
 
  def commit(self):
    self.holder.commit()

  def to_string(self):
    for pkt in self.holder.contents:
      return str(pkt.last_f - pkt.first_f)
    return "0"
